import Vue from "vue";
import VueRouter from "vue-router";
import Login from "../views/Login.vue";
import Main from "../views/Main.vue";
import NotFound from "../views/NotFound.vue";

//引入二级组件
import GlobalSettings from "../views/GlobalSettings.vue";
import TableList from "../views/TableList.vue";
import TableAdd from "../views/TableAdd.vue";
import TableDelete from "../views/TableDelete.vue";
import CategoryList from "../views/CategoryList.vue";
import CategoryAdd from "../views/CategoryAdd.vue";
import CategoryDelete from "../views/CategoryDelete.vue";
import CategoryUpdate from "../views/CategoryUpdate.vue";
import DishList from "../views/DishList.vue";
import DishAdd from "../views/DishAdd.vue";
import DishDelete from "../views/DishDelete.vue";
import DishUpdate from "../views/DishUpdate.vue";
import OrderList from "../views/OrderList.vue";
import Security from "../views/Security.vue";

//引入组件

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    //重定向到login 如果没输入网址的话
    redirect: "/login",
  },
  {
    path: "/login",
    name: "Login",
    component: Login,
  },
  {
    path: "/main",
    component: Main,
    // 2级路由 加/可不带main直接访问
    children: [
      //重定向默认指向
      { path: "", redirect: "/table/list" },
      { path: "/settings", component: GlobalSettings },
      { path: "/table/list", component: TableList },
      { path: "/table/add", component: TableAdd },
      { path: "/table/delete", component: TableDelete },
      { path: "/category/list", component: CategoryList },
      { path: "/category/add", component: CategoryAdd },
      { path: "/category/delete", component: CategoryDelete },
      { path: "/category/update", component: CategoryUpdate },
      { path: "/dish/list", component: DishList },
      { path: "/dish/add", component: DishAdd },
      { path: "/dish/delete", component: DishDelete },
      { path: "/dish/update", component: DishUpdate },
      { path: "/order/list", component: OrderList },
      { path: "/security", component: Security },
    ],
  },
  // 除以上地址 其他错误地址将跳转notFound
  {
    path: "*",
    component: NotFound,
  },
];

const router = new VueRouter({
  routes,
});

export default router;
